package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.DimensionMapper;
import com.tanhua.model.domain.Dimension;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class DimensionApiImpl implements DimensionApi {

    @Autowired
    private DimensionMapper dimensionMapper;

    @Override
    public String findById(Integer dimensionId) {
        LambdaQueryWrapper<Dimension> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Dimension::getId, dimensionId);
        Dimension dimension = dimensionMapper.selectOne(lqw);
        return dimension.getName();
    }

    @Override
    public Dimension findTypeByName(String maxValue) {
        LambdaQueryWrapper<Dimension> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Dimension::getName, maxValue);
        return dimensionMapper.selectOne(lqw);
    }
}
